import { createVNode } from './my-vdom'

const createElement = function(type, props, ...children) {

    props.children = children
    delete props.__source
    delete props.__self

    let vtype;
    if (typeof type === 'string') {
        vtype = 1
    } else if (typeof type === 'function') {
        if (type.isClassComponent === true) {
            vtype = 2 // 类组件
        } else {
            vtype = 3 // 函数组件
        }
    }   

    return createVNode(vtype, type, props)
}

export class Component {

    static isClassComponent = true;

    constructor(props) {
        this.props = props
        this.state = {}
    }
    setState(state) {
        // do some
    }
}

export default {
    createElement,
    Component
}
